$(function () {

    var _user = null, _thisPage = null, html = [], _passType = "", _phone = "";


    var validatePage = function () {
        this.init();
    };

    validatePage.prototype = {
        init: function () {
            this.initData();
            this.bindEvent();
        },
        initData: function () {
            _user = getLocalStorage(STORAGE_MANAGER.user);
            if (!_user) {
                redirect("login.html");
                return false;
            }

            _passType = getUrlParam("type");
            _phone = getUrlParam("phone");
            $("#phone").html(_phone).attr("tip", _user.id);
        },
        bindEvent: function () {
            //回退
            $("#back").on("tap", function () {
                back();
            });

            //点击获取验证码
            $("#getVcode").on("tap", function () {
                change_code(this, $("#phone"), SMS_TYPE.verify);
            });

            //点击下一步
            $("#nextStep").on("tap", function () {
                //验证码
                if ('' == $("#vcode").val().trim()) {
                    $.alert("请填写验证码");
                    return false;
                } else if (!isVCode($("#vcode").val().trim())) {
                    $.alert("验证码格式不正确");
                    return false;
                } else {
                    //跳转
                    var parm = {"type": _passType, "vcode": $("#vcode").val().trim()};
                    console.log(JSON.stringify(parm));
                    setPageParams("validatePhone_html", parm);

                    redirect("editPass.html");
                    return false;
                }

            });
        }
    }

    _thisPage = new validatePage();

});
